#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @Project  :main.py
# @Date     :2021/1/23 9:06 下午
# @Author   :JIAN LI
# @Email    :lijianjlu@126.com

# 导入相关依赖库
import cv2 as cv
import numpy as np

# 1.图像读取
img_path = 'imgs/1.jpg'
img = cv.imread(img_path)

# 2.图像尺寸获取
height = img.shape[0] # 图像高度
width = img.shape[1] # 图像宽度
channel = img.shape[2] # 图像通道数

# 3.图像裁剪
img2 = img[10:,10:]

# 4.图像缩放
w = 50 # 缩放后的宽度
h = 50 # 缩放后的高度
img3 = cv.resize(img,(w,h))

# 5.图像叠加
img[0:50,0:50] = img3

# 6.在图像画方框
x = 30 # 方框起始点的横坐标
y = 30 # 方框起始点的纵坐标
draw0 = cv.rectangle(img, (x,y),(x+w,y+w),(255,0,0),2) # 参数：待操作图像，方框起始点坐标，方框终止点坐标，方框颜色，方框线条粗细

# 7.在图像上画直线
ptstart = (0,0)
ptend = (100,100)
pt_color = (0,255,0)
thickness = 1
line_type = 4
cv.line(img, ptstart, ptend, pt_color, thickness, line_type)

# 8.图像显示
cv.imshow('window_name',img)

cv.waitKey(0)
cv.destroyAllWindows()
